//
//  AXHdzqMsJjkqCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/1.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHdzqMsJjkqCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@implementation AXHdzqMsJjkqCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
       
    }
    return self;
}

- (void)creatView {
   
    
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.font = FONT_FOURTEEN;
    self.productNameLabel.numberOfLines = 2;
    self.productNameLabel.textColor = [UIColor colorWithHex:0x666666];
    [self.contentView addSubview:self.productNameLabel];
    /** 产品价格 */
    self.oldPriceLabel = [[UILabel alloc]init];
    self.oldPriceLabel.text = @"12";
    self.oldPriceLabel.textColor = COLOR_Gray;
    self.oldPriceLabel.font = FONT_TWELVE;
    [self.contentView addSubview:self.oldPriceLabel];
    
    
    self.nowPriceLabel = [[UILabel alloc]init];
    self.nowPriceLabel.text = @"34";
    self.nowPriceLabel.textColor =COLOR_ORG;
    self.nowPriceLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.nowPriceLabel];
    
    
    self.startTimeLabel = [[UILabel alloc]init];
    self.startTimeLabel.textColor =COLOR_Gray;
    self.startTimeLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.startTimeLabel];
    
    
    
    
    
    
    /** 去支付*/
    self.shopButton = [[UIButton alloc]init];
    self.shopButton.titleLabel.font = FONT_FOURTEEN;;
    self.shopButton.backgroundColor = COLOR_ORG;
    [self.shopButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.shopButton setTitle:@"提醒我" forState:UIControlStateNormal];
    [self.contentView addSubview:self.shopButton];
    
    
    
    
}

- (void)setlayout {
  
    /* 产品图片 **/
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView,10)
    .widthIs(100)
    .heightIs(100);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(40);
    
    /* 产品原价 **/
    self.oldPriceLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.productNameLabel, 10)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(20);
    
    self.nowPriceLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.oldPriceLabel, 10)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(20);
    
    self.startTimeLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.nowPriceLabel, 10)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(20);
   
 
    /** 去支付按钮 */
    self.shopButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topEqualToView(self.nowPriceLabel)
    .widthIs(100)
    .heightIs(30);
    
    
    /** cell高度自适应第一步 */
    [self setupAutoHeightWithBottomView:self.startTimeLabel bottomMargin:10];
    
}



- (void)setModel:(AXHdzqMsZzfqListModel *)model {
    
    _model = model;
    
    [self.productImageView sd_setImageWithURL:[NSURL URLWithString:_model.seckillLogo] placeholderImage:[UIImage imageNamed:@"placeHold"]];
    _productNameLabel.text = _model.seckillName;
    _nowPriceLabel.text = _model.seckillPrice;
    /** 删除线 */
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:_model.goodsOriginalTotalPrice
                                                                                attributes:@{NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle)}];
    self.oldPriceLabel.attributedText = attrStr;
    self.startTimeLabel.text = _model.startDatetime;
    
     [self setlayout];
    
}


@end
